package com.ztz.mynewdemo.adapter;

import android.content.Context;
import android.content.Intent;
import android.view.View;

import com.ztz.mynewdemo.R;
import com.ztz.mynewdemo.activity.ScienceActivity;
import com.ztz.mynewdemo.bean.ScienceResponse;

import java.util.List;

/**
 * Created by wqewqe on 2017/12/19.
 */

public class ScienceAdapter2 extends CommonRecyclerAdapter<ScienceResponse.ResultBean.DataBean> {
    Context context;
    public ScienceAdapter2(Context mContext, List<ScienceResponse.ResultBean.DataBean> mDatas, int mLayoutId) {
        super(mContext, mDatas, mLayoutId);
        context=mContext;
    }

    @Override
    public void convert(ViewHolder holder, final ScienceResponse.ResultBean.DataBean items) {
        holder.setImageUrl(R.id.iv_top,items.getThumbnail_pic_s());
        holder.setText(R.id.top_title,items.getTitle());
        holder.setText(R.id.topLine_data,items.getDate());
        holder.setText(R.id.tv_category,items.getCategory());
        holder.setText(R.id.tv_author,items.getAuthor_name());
        holder.setOnItemClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent=new Intent(context, ScienceActivity.class);
                intent.putExtra(ScienceActivity.SOCIETY_ID,items.getUrl());
                intent.putExtra(ScienceActivity.TITLE,items.getTitle());
                intent.putExtra(ScienceActivity.DATE,items.getDate());
                intent.putExtra(ScienceActivity.CATEGORY,items.getCategory());
                intent.putExtra(ScienceActivity.AUTHOR,items.getAuthor_name());
                intent.putExtra(ScienceActivity.IMAGE,items.getThumbnail_pic_s());
                context.startActivity(intent);
            }
        });
    }
}
